<template>
  <div>
    <van-nav-bar
      title="欢迎搜索"
      left-text="返回"
      left-arrow
      @click-left="
        () => {
          $router.back('/home');
        }
      "
    />

    <van-search
      v-model="sou"
      shape="round"
      background="#fff"
      placeholder="请输入搜索关键词"
      @click="sousuo"
    />
    <!-- 单元格 -->
    <van-cell-group v-for="i in sousuoData">
      <router-link :to="'/detail/' + i.goods_id">
        <van-cell :title="i.goods_name" />
      </router-link>
    </van-cell-group>
  </div>
</template>

<script setup>
import { watch, ref } from "vue";
let sou =ref("")
import { sousuoApi } from "@/api/api";
let sousuoData=ref([])
watch(sou,(sou)=>{
    sousuoApi(sou).then((res)=>{
        console.log('搜索',res);
        sousuoData.value=res.data.message
    })
})
</script>

<style lang="scss" scoped>
</style>